slice method to reverse a string